﻿using System.ComponentModel.DataAnnotations;
using bpms.Enums;

namespace bpms.Models
{
    /// <summary>
    /// 注册视图模型
    /// </summary>
    public class RegisterViewModel
    {
        [Required(ErrorMessage ="用户类型必选")]
        [Display(Name = "用户类型")]
        public UserType UserType { get; set; } = UserType.Admin;

        // 公共字段
        [Required(ErrorMessage = "登录名必填")]
        [StringLength(50)]
        [Display(Name = "登录名")]
        public string LoginName { get; set; }

        [Required(ErrorMessage = "密码名必填")]
        [StringLength(50)]
        [DataType(DataType.Password)]
        [Display(Name = "密码")]
        public string Password { get; set; }

        [Required(ErrorMessage = "确认密码不能为空")]
        [Compare("Password", ErrorMessage = "两次密码不一致")]
        [DataType(DataType.Password)]
        public string ConfirmPassword { get; set; }

        [Required(ErrorMessage = "姓名必填")]
        [StringLength(50)]
        [Display(Name = "姓名")]
        public string Name { get; set; }

        // 买家专属
        [Display(Name = "电话")]
        [Required(ErrorMessage = "电话必填")]
        //[RequiredIf(nameof(UserType), UserType.Buyer, ErrorMessage = "电话为必填项")]
        public string Phone { get; set; }

        [Display(Name = "地址")]
        [Required(ErrorMessage = "地址必填")]
        //[RequiredIf(nameof(UserType), UserType.Buyer, ErrorMessage = "地址为必填项")]
        public string Address { get; set; }
    }
}
